package com.ostrich.shopping.base;

import android.content.Intent;
import android.os.Bundle;

import com.gyf.immersionbar.ImmersionBar;
import com.ostrich.shopping.R;


import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;


public abstract class BaseActivity<VDB extends ViewDataBinding> extends AppCompatActivity {
   protected VDB binding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ImmersionBar
                .with(this)
                .fitsSystemWindows(true)//解决状态栏和布局重叠问题，任选其一
                .statusBarColor(R.color.purple_200)//状态栏颜色，不写默认透明色
                .init();
        binding = DataBindingUtil.setContentView(this,getLayout());
        iniView();
        initData();
        initListener();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        binding = null;
    }

    protected abstract void iniView();

//    public abstract int getStatusBarColor();
   public abstract int getLayout();
   public abstract void initData();
   public abstract void initListener();

   public void startActivity(Class tClass){
       Intent intent = new Intent(this, tClass);
       startActivity(intent);
   }

    public void startActivityBundle(Class tClass,Bundle bundle){
        Intent intent = new Intent(this, tClass);
        intent.putExtras(bundle);
        startActivity(intent);
    }

    public Bundle getBundle(){
       return getIntent().getExtras();
    }




}
